<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
The Buggy Program
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial037.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial039.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc78">5.1</A>&nbsp;&nbsp;The Buggy Program</H2>
The program we will be debugging is a map colouring problem. The 
task is to colour a
`map' of countries with four colours such that no two neighbours have the
same colour. Our program colours a map of four countries, but has a bug and
can colour two neighbours the same colour. The map is displayed graphically
as shown: <BR>
<BR>
<DIV CLASS="center">
<IMG SRC="tutorial003.gif"><BR>
<BR>
<BR>

<B>Map Display of Program</B>
</DIV><BR>
<BR>
The countries are identified by numbers displayed within each country, and 
in this case, an incorrect colouring for the map is shown, because
countries 3 and 4 have the same colour. <BR>
<BR>
This program uses code from the map colouring demo program, and is
designed to use the GUI to display a map. Most of this is
not relevant to our debugging session, and although we will see some of this
code during the debugging, it is not necessary to understand it. 
You can think of this
debugging session as debugging someone else's code, not all of which
needs to be understood.<BR>
<BR>
The program used here is included with your ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> distribution. You
should find it under the <TT>doc/examples/tutorial</TT> directory. You can
change to the <TT>examples</TT> directory in TkECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> using the
<TT>Change to example directory</TT> option from the <TT>File</TT> menu.<BR>
<BR>
The final step in this debug tutorial is to edit the buggy program and
correct it. If you want to do this, you should copy the distributed version
of the program elsewhere so that you don't edit the original. You need to
copy the following files from <CODE>examples/tutorial</CODE> to another directory:
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
debugdemo.ecl  mapcolour.ecl mapdebugdemo.tcl buggy_data.map
</PRE></BLOCKQUOTE>
To load the program, start TkECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>. After start up, 
switch the working directory to
where you have the programs &ndash; if you are using a UNIX system, and have
started TkECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> in the directory of the programs, you are already
there. Otherwise, go to the <TT>File</TT> menu of TkECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>, and select
the <TT>Change directory</TT> option. Use the directory browser to find
the directory containing your programs and select it. This will change your
working directory to the selected directory.<BR>
<BR>
Next, compile <CODE>debugdemo.ecl</CODE>. You can do this by selecting the
<TT>Compile</TT> option from the <TT>File</TT> menu (you can also compile
the file with the query <CODE>[debugdemo]</CODE> from the query entry
window). <BR>
<BR>
<HR>
<A HREF="tutorial037.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial039.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
